package com.shop.interceptors;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.shop.entity.UserInfo;

public class MyMethodFilterInterceptor extends MethodFilterInterceptor {

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		UserInfo userInfo = (UserInfo) invocation.getInvocationContext().getSession().get("user");
		if(userInfo==null){
			return Action.LOGIN;
		}else if(userInfo.getRoleId() == 1){
			return invocation.invoke();
		}else{
			invocation.getInvocationContext().put("msg", "你不是管理员,权限不足.");
			return Action.LOGIN;
		}
	}

}
